%macro C 0
	enter 0,0
	push esi
	push edi
	push ebx
%endmacro
%macro endC 0
	push ebx
	push edi
	push esi
	leave
	ret
%endmacro

section .text
extern malloc
global maximo
global productoEscalar
global productoInterno

maximo:
	C
	mov ebx,[ebp+8]
	xor ecx,ecx
	mov cx,[ebp+12]
	mov eax,[ebx]
	lea ecx,[ecx-4]
	.loop:
		lea ebx,[ebx+4]
		cmp [ebx],eax
		cmovg eax,[ebx]
	loop .loop
	endC

productoEscalar:
	C
	xor ecx,ecx
	mov cx,[ebp+16]
	lea eax,[ecx*8]
	push ecx
	push eax
	call malloc
	mov edi,eax
	pop eax
	pop ecx
	mov ebx,[ebp+8]
	push edi
	.loop:
		mov eax,[ebx]
		imul dword [ebp+12]
		mov dword [edi],eax
		mov dword [edi+4],edx
		lea ebx,[ebx+4]
		lea edi,[edi+8]
	loop .loop
	pop eax
	endC

productoInterno:
	C
	xor ecx,ecx
	mov cx,[ebp+16]
	mov esi,[ebp+8]
	mov edi, [ebp+12]
	xor ebx,ebx
	push 0
	.loop:
		xor eax,eax
		xor edx,edx
		mov ax,[esi]
		imul word [edi]
		add ebx,eax
		adc [esp+4],edx
		lea esi,[esi+2]
		lea edi,[edi+2]
	loop .loop
	mov eax,ebx
	pop edx
	endC
